<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="box"></div>
</body>
<script>
    function getTime(time){
        var d1=new Date(time);
        var d2=new Date();
        var time=d1-d2;
        var d = Math.abs(parseInt(time / 1000 / 60 / 60 / 24));
        var h = Math.abs(parseInt(time / 1000 / 60 / 60 % 24));
        var m = Math.abs(parseInt(time / 1000 / 60 % 60));
        var s = Math.abs(parseInt(time / 1000 % 60));
        return d + '天' + h + '时' + m + '分' + s + '秒';
    }
    var box=document.getElementsByClassName('box')[0];
    setInterval(
        function(){
            box.innerHTML=getTime('2024-4-18');
        },1000
    )
</script>
</html>